import { ModuleManager } from "odin";
import { WeaponModuleC } from "../../../JavaScripts/modules/weapon/WeaponModule";

/*
 * @Author: zhaolei
 * @Date: 2022-08-01 10:18:03
 * @LastEditors: zhaolei
 * @Description: file content
 */
@MWCore.MWClass
export default class WeaponPick extends MWCore.MWScript {
	@MWCore.MWProperty({ displayName: "武器ID" })
	public weaponId: number = 0;
	private _trigger: GamePlay.Trigger;

	/** 当脚本被实例后，会在第一帧更新前调用此函数 */
	protected onStart(): void {
		this._trigger = this.gameObject as GamePlay.Trigger;
		this._trigger.onEnter.add((gameObject) => {
			if (GamePlay.isCharacter(gameObject)) {
				ModuleManager.instance.getModule(WeaponModuleC).pickWeapon((gameObject as GamePlay.Character).player, this.weaponId);
			}
		});
	}

	/** 
	 * 每帧被执行,与上一帧的延迟 dt 秒
	 * 此函数执行需要将this.bUseUpdate赋值为true
	 */
	protected onUpdate(dt: number): void {

	}

	/** 脚本被销毁时最后一帧执行完调用此函数 */
	protected onDestroy(): void {

	}

}
